import React, { Component, useState, useRef } from "react";
import classNames from "classnames";
import "./index.css";
export default function K() {
  let [value, setValue] = useState("");
  let iptRef = useRef();
  let searchVal = () => {
    console.log(iptRef.current.value, "iptRef.current.value");
    console.log(value, "value");
  };
  return (
    <>
      <h1>表单受控</h1>
      <input
        value={value}
        ref={iptRef}
        onChange={(e) => setValue(e.target.value)}
        type="text"
      />
      <button onClick={searchVal}>打印input的值</button>
    </>
  );
}
